package org.wu.framework.easy.excel.endpoint.convert;

import org.wu.framework.core.stereotype.converter.LayerAnnotationConverterAdapter;
import org.wu.framework.easy.excel.endpoint.EasyExcelFieldPoint;
import org.wu.framework.easy.excel.stereotype.EasyExcelField;

/**
 * describe : 将注解转换成端点信息
 *
 * @author : Jia wei Wu
 * @version 1.0
 * @date : 2023/1/2 19:03
 */
public class EasyExcelFiledPointConvert implements LayerAnnotationConverterAdapter<EasyExcelField, EasyExcelFieldPoint> {


    /**
     * 是否支持
     *
     * @param annotation          注解
     * @param easyExcelFieldPoint 断点
     * @return
     */
    @Override
    public boolean supports(EasyExcelField annotation, EasyExcelFieldPoint easyExcelFieldPoint) {
        return true;
    }

    /**
     * @param annotation 原始注解
     * @return 返回断点信息
     */
    @Override
    public EasyExcelFieldPoint converter(EasyExcelField annotation) {

        EasyExcelFieldPoint easyExcelFieldPoint = new EasyExcelFieldPoint();
        easyExcelFieldPoint.setName(annotation.name());
        easyExcelFieldPoint.setWidth(easyExcelFieldPoint.getWidth());
        easyExcelFieldPoint.setWrapText(annotation.wrapText());
        easyExcelFieldPoint.setFillPatternType(annotation.fillPatternType());
        easyExcelFieldPoint.setTitleBackgroundColor(annotation.titleBackgroundColor());
        easyExcelFieldPoint.setTitleFontColor(annotation.titleFontColor());
        easyExcelFieldPoint.setTitleFontName(annotation.titleFontName());
        easyExcelFieldPoint.setTitleFontSize(annotation.titleFontSize());
        easyExcelFieldPoint.setColumnFontColor(annotation.columnFontColor());
        easyExcelFieldPoint.setColumnFontName(annotation.columnFontName());
        easyExcelFieldPoint.setColumnFontSize(annotation.columnFontSize());
        easyExcelFieldPoint.setColumnBackgroundColor(annotation.columnBackgroundColor());
        easyExcelFieldPoint.setDropdownOptions(annotation.dropdownOptions());
        easyExcelFieldPoint.setFieldMerge(annotation.fieldMerge());
        easyExcelFieldPoint.setSerialNumber(annotation.serialNumber());
        return easyExcelFieldPoint;
    }


}
